package com.basic.library.view.hover;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;

/**
 * @author yj
 * @description 分组悬停
 */
public class SuspensionRecycleView extends FrameLayout {
    SectionRecycleView recycleView;

    public SuspensionRecycleView(Context context) {
        this(context, null);
    }

    public SuspensionRecycleView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SuspensionRecycleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        addView();
    }

    public SectionRecycleView getRecycleView() {
        return recycleView;
    }

    void addView() {
        recycleView = new SectionRecycleView(getContext());
        addView(recycleView);
        LayoutParams params = (LayoutParams) recycleView.getLayoutParams();
        params.width = LayoutParams.MATCH_PARENT;
        params.height = LayoutParams.MATCH_PARENT;
    }

    public void addSuspensionBar(int mSuspensionBarID, SectionRecycleView.SuspensionCallback mSuspensionCallback) {
        View mSuspensionBar = View.inflate(getContext(), mSuspensionBarID, null);
        addView(mSuspensionBar);
        LayoutParams params = (LayoutParams) mSuspensionBar.getLayoutParams();
        params.width = LayoutParams.MATCH_PARENT;
        params.height = LayoutParams.WRAP_CONTENT;
        if (recycleView != null) {
            recycleView.setmSuspensionBar(mSuspensionBar);
            recycleView.addSuspensionCallback(mSuspensionCallback);
        }
    }
}
